/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-08-27
 * Time: 19:32
 */
public class Test {
    private int getBit(int n) {
        int count = 0;
        while(n != 0) {
            n = n & (n-1);
            count++;
        }

        return count;
    }

    public int[] countBits(int n) {
        int[] ret = new int[n+1];
        for(int i = 1; i <= n; i++) {
            ret[i] = getBit(i);
        }

        return ret;
    }
}
